package _28define.udp.twoPerson;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class receiverTask implements Runnable{
    DatagramSocket datagramSocket;

    public receiverTask(DatagramSocket datagramSocket) {
        this.datagramSocket = datagramSocket;
    }

    @Override
    public void run() {
        while (true){
            try {
                datagramSocket=new DatagramSocket();
                byte[] bytes=new byte[1024];
                DatagramPacket receiverPacket=new DatagramPacket(bytes,0,bytes.length);
                datagramSocket.receive(receiverPacket);
                byte[] date=receiverPacket.getData();
                int offset=receiverPacket.getOffset();
                int length=receiverPacket.getLength();
                String msg=new String(date,offset,length);
            } catch (IOException e) {
                e.printStackTrace();
            }


        }
    }
}
